import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class SecondWindow {

    public void Window2(){

        //创建第二个窗口
        JFrame secondFrame = new JFrame("记账");
        secondFrame.setBounds(10,500,500,500);

        JPanel Panel = new JPanel(new GridLayout(1, 2));

        //创建两个按钮
        JButton incomeButton = new JButton("收入");
        incomeButton.setPreferredSize(new Dimension(120, 70));
        String text1 = incomeButton.getText(); // 获取按钮上的文本
        incomeButton.setFont(new Font("宋体", Font.PLAIN, 20));
        incomeButton.setText(text1);

        incomeButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ThirdWindow third1Window = new ThirdWindow();
                third1Window.Window31();
            }
        });

        JButton expenseButton = new JButton("支出");
        expenseButton.setPreferredSize(new Dimension(120, 70));
        String text2 = expenseButton.getText(); // 获取按钮上的文本
        expenseButton.setFont(new Font("宋体", Font.PLAIN, 20));
        expenseButton.setText(text2);

        expenseButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ThirdWindow third2Window = new ThirdWindow();
                third2Window.Window32();
            }
        });

        Panel.add(incomeButton);
        Panel.add(expenseButton);

        secondFrame.add(Panel,BorderLayout.CENTER);

        // 显示第二个窗口
        secondFrame.pack();
        secondFrame.setSize(600,300);
        secondFrame.setVisible(true);




    }
}
